
/**
 * 弹出选择用户（员工）菜单，
 * 
 * @param showSelect :页面员工是否允许多选。（是否出现checkBox）
 * @param argObjs:需要带入的参数
 * 
 * @return 返回以员工ID为key，名称为value的Map类型
 */
function selectUsersFromWindow(showSelect,argObjs){
   url = __CONTEXT_PATH + "jsp/framework/sys/user/userSelectWindow.jsp";
   if (showSelect) {
	   url += "?&showSelect=" + showSelect;
   }
   var feather = "dialogWidth:700px;dialogHeight:520px;help:no;status:0;edge:sunkey;resizable:yes;";
   var str_arrays = window.showModalDialog(url, argObjs, feather);
   return  getMapArrays(str_arrays);
}
/**
 * 弹出考核阶段对应的员工菜单，返回以员工ID为key，名称为value的Map类型<<<考核方案模块>>>>
 * 
 * @param segmentId :考核阶段ID（必选项）
 * @param showSelect :页面员工是否允许多选。（是否出现checkBox）
 * @param argObjs:需要带入的参数
 * 
 * @return 返回以员工ID为key，名称为value的Map类型
 */
function selectTaskUsersFromWindow(segmentId,showSelect,argObjs){
   url = __CONTEXT_PATH + "jsp/perform/khyg/task/taskUserWindow.jsp?&segmentId="+segmentId;
   if (showSelect) {
	   url += "&showSelect=" + showSelect;
   }
   var feather = "dialogWidth:700px;dialogHeight:520px;help:no;status:0;edge:sunkey;resizable:yes;";
   var str_arrays = window.showModalDialog(url, argObjs, feather);
   return  getMapArrays(str_arrays);
}



/*********************select标签功能扩展********************/
function delOption(sourceObj){
    for (var i=0;i<sourceObj.length;i++) {
        if (sourceObj(i).selected) {
           sourceObj.remove(i--);
        }
    }
}
function clearOption(sourceObj){
    while (sourceObj.length > 0){
        sourceObj.remove(0);
    }
}
function addOption(selectObj, optText,optValue){
    var contains = containsKey(selectObj,optText,optValue);
     if (!contains){
        selectObj.options.add(new Option(optText,optValue));
     }
     return contains;
}
function containsKey(selectObj,optionText,optionValue){
    for (var i=0;i<selectObj.length;i++){
        if (selectObj[i].text==optionText && selectObj[i].value==optionValue){
           return true;
        }
    }
    return false;
}
/*********************Map面向对象扩展********************/
function Map(){
    this.array = new Array();
}
Map.prototype.put=function(key, value){
    var index = this.indexOf(key);
    if (index == -1){
        this.array.push(key);
        this.array.push(value);
    }else{
        this.array[index+1] = value;
    }
}
Map.prototype.get=function(key){
    for (var i=0,len=this.array.length; i<len; i+=2){
        if (this.array[i] == key){
            return this.array[i+1];
        }
    }
    return null;
}
Map.prototype.remove=function(key){
    var index = this.indexOf(key);
    if (index != -1){
        this.array.splice(index, 2);
    }
}
Map.prototype.keys=function(){
    var keySet = new Array();
    var len=this.array.length / 2;
    for (var i=0; i<len; i++){
        keySet.push(this.array[2*i]);
    }
    return keySet;
}
Map.prototype.toString=function(){
    var str = "{";
    for (var i=0,len=this.array.length; i<len; i+=2){
        str += (this.array[i]+":"+this.array[i+1]+"; ");
    }
    if (str.length > 1){
        str = str.substring(0, str.length-2);
    }
    str += "}";
    return str;
}
Map.prototype.indexOf=function(key){
    for (var i=0,len=this.array.length; i<len; i+=2){
        if (this.array[i] == key){
            return i;
        }
    }
    return -1;
}
Map.prototype.build=function(render){
    this.array = new Array();
    render = render.substring(1, render.length-1).split(";");
    var element, index;
    for (var i=0,len=render.length; i<len; i++){
        element = render[i];
        index = element.indexOf(":");
        this.array.push(element.substring(0, index).trim());
        this.array.push(element.substring(index+1, element.length));
    }
    return this;
}
/**
 * 把弹出框返回的字符串转换成JSON类型对象，如：{userId:001;userName:员工1},{userId:002;userName:员工2}
 */
function getMapArrays(render, splitor){
    if (splitor==null || splitor==undefined){
        splitor = "|";
    }
    var map_arrays = new Array();
    if (render!=null && render!=undefined && render.length>0){
        var str_arrays = render.split(splitor);
        for (var i=0,len=str_arrays.length; i<len; i++){
            var map = new Map();
            map = map.build(str_arrays[i]);
            map_arrays.push(map);
        }
    }
    return  map_arrays;
}
/*********************Array扩展********************/
Array.prototype.indexOf=function(str){
    for (var i=0,len=this.length; i<len; i++){
        if (str == this[i]){
           return i;
        }
    }
    return -1;
}
/*********************Other********************/
function isEmpty_JSon(str){
	return str == null || str.Trim() == "" || str.Trim() == '%@|$';	
}

//只能是数字、字母、中文，长度1－100 author:linyd
 function chk_name_lin(LName){
	var val = LName;
	var key = "/1-100/怪字符/全数字/无内容/划线/有全角/有空格/";
	if(key.indexOf("/无内容/")>-1&&val==""){
		return false;
	}
	if(key.indexOf("/1-100/")>-1&&(strLen(val)<1||strLen(val)>100)){
		return false;
	}
	if(key.indexOf("/怪字符/")>-1&&(/>|<|,|\[|\]|\{|\}|\?|\/|\+|=|\||\'|\\|\"|:|;|\~|\!|\@|\#|\*|\$|\%|\^|\&|\(|\)|`/i).test(val)){
		return false;
	}
	if(key.indexOf("/划线/")>-1&&(val.indexOf("-")>-1)){
		return false;
	}
	if(key.indexOf("/有空格/")>-1&&val.indexOf(" ")>-1){
		return false;
	}
	if(key.indexOf("/有大写/")>-1&&/[A-Z]/.test(val)){
		return false;
	}
	if(key.indexOf("/有全角/")>-1&&/[ａ-ｚＡ-Ｚ０-９！＠＃￥％＾＆＊（）＿＋｛｝［］｜：＂＇；．，／？＜＞｀～　]/.test(val))
		{
			return false;
		}			
	return true;
}